<?php
require_once 'models/models_user.php';
$mod = $_GET['mod'];
$obuser = new models_user();
switch ($mod)
{
	case 'dangky':{  
			if($_POST){
				$data['list']=$obuser->_getusers($_POST['txtuser']);
				$data['listdt']=$obuser->_getdt($_POST['txtdienthoai']);
				if(!$data['list']){
				if(!$data['listdt'] ){
				if($_POST['mk']==$_POST['nlmk']){
				if($_POST['txtCaptcha'] == $_SESSION['security_code'] )
					{
						$pass=md5($_POST['mk']);
						$obuser->addUserdangky($_POST['txtuser'],$pass, $_POST['txtdienthoai'],$_POST['txtmail'],$_POST['txtdiachi'],$_POST['txthovaten']);
						echo '<script>window.location.href="index.php?mod=dangkythanhcong"</script>';
					}else{
						$err="Mã bảo vệ sai!";
					echo '<script>window.location.href="index.php?mod=dangky"</script>';
					}
					
				}else{
					echo "Mật khẩu không trùng nhau !";
					echo '<script>window.location.href="index.php?mod=dangky"</script>';
				}
				
				}else{
					echo "Số điện thoại đã có !";
					echo '<script>window.location.href="index.php?mod=dangky"</script>';
				}
			
			}else{
					echo "Tên đăng nhập đã có !";
					echo '<script>window.location.href="index.php?mod=dangky"</script>';
			}
			}
		require 'views/main/dangky/index.php';
		break;
	}
		case 'dangkythanhcong':
		{
			require_once 'views/main/dangky/dangkythanhcong.php';
			break;
		}
		case 'suathongtincanhan':{
			if($_POST){
				$obuser->updateuser($_POST['txtdienthoai'],$_POST['txtmail'], $_POST['txtdiachi'], $_POST['txthovaten'], $_GET['id']);
				echo '<script>window.location.href="index.php?mod=capnhatthanhcong"</script>';
			}	
		$user=$obuser->getuser($_GET['id']);
		require_once 'views/main/dangky/suathongtincanhan.php';
		break;	
    }
    case 'capnhatthanhcong':
		{
			require_once 'views/main/dangky/capnhatthanhcong.php';
			break;
		}
		
}